<?php if ($this->frontwebsite()->getUserIni('user_register_state') == 'true') { ?>
<form class="validforms" method="post" enctype="multipart/form-data" name="formLogin">
    <div class="flow-consignee ect-bg-colorf">
        <ul>
            <li>
                <div class="input-text"><b><?php echo $this->translate('用户名'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="text" errormsg="<?php echo $this->translate('用户名必须为2-30个字符'); ?>" datatype="*2-30" id="user_name" name="user_name" ajaxurl="<?php echo $this->url('m_user/default/user_id',array('action'=>'check','controller'=>'user','check_type'=>'user_name','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>" placeholder="<?php echo $this->translate('请输入用户名'); ?>" nullmsg="<?php echo $this->translate('请输入用户名'); ?>">
                </span></div>
            </li>
            <li>
                <div class="input-text"><b><?php echo $this->translate('登录密码'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="password" datatype="*6-16" name="user_password" class="inputBg" placeholder="<?php echo $this->translate('请输入登录密码'); ?>" nullmsg="<?php echo $this->translate('请输入登录密码'); ?>">
                </span></div>
            </li>
            <li>
                <div class="input-text"><b><?php echo $this->translate('确认密码'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="password" datatype="*6-16" name="user_com_passwd" recheck="user_password"  class="inputBg" placeholder="<?php echo $this->translate('请输入确认密码'); ?>" nullmsg="<?php echo $this->translate('请输入确认密码'); ?>" errormsg="<?php echo $this->translate('您两次输入的账号密码不一致！'); ?>">
                </span></div>
            </li>
            <?php
            $userEmailRegisterState = $this->frontwebsite()->getRegOrLoginIni('register_email_state');
            $userPhoneRegisterState = $this->frontwebsite()->getRegOrLoginIni('register_phone_state');

            $userPhoneCaptchaState = $this->frontwebsite()->websiteCaptchaState('phone_user_register_captcha');
            ?>
            <?php if ($userEmailRegisterState == 'true') { ?>
                <li>
                    <div class="input-text"><b><?php echo $this->translate('电子邮箱'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="text" datatype="e" id="user_email" name="user_email" ajaxurl="<?php echo $this->url('m_user/default/user_id',array('action'=>'check','controller'=>'user','module'=>'user','check_type'=>'user_email','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>" placeholder="<?php echo $this->translate('请输入电子邮箱'); ?>" nullmsg="<?php echo $this->translate('请输入电子邮箱'); ?>">
                </span></div>
                </li>
            <?php } ?>
            <?php if ($userPhoneRegisterState == 'true') { ?>
                <li>
                    <div class="input-text"><b><?php echo $this->translate('手机号码'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="text" datatype="m" id="user_phone" name="user_phone" ajaxurl="<?php echo $this->url('m_user/default/user_id',array('action'=>'check','controller'=>'user','module'=>'user','check_type'=>'user_phone','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>" placeholder="<?php echo $this->translate('请输入手机号码'); ?>" nullmsg="<?php echo $this->translate('请输入手机号码'); ?>" errormsg="<?php echo $this->translate('手机号码格式错误'); ?>">
                </span></div>
                </li>
                <?php if($userPhoneCaptchaState == 'true') { ?>
                    <li>
                        <div class="input-text code"><b><?php echo $this->translate('手机验证码'); ?><font class="must_add_value">*</font>：</b><span>
                        <input type="text" datatype="*" id="phone_captcha" style="width: 80%;" name="phone_captcha" ajaxurl="<?php echo $this->url('mobile/default',array('action'=>'checkphoneCaptcha')); ?>" placeholder="<?php echo $this->translate('请输入手机验证码'); ?>" nullmsg="<?php echo $this->translate('请输入手机验证码'); ?>">
                        </span>
                            <input type="button"class="pull-right" id="get_phone_captcha" value="<?php echo $this->translate('获取验证码'); ?>">
                            <input type="hidden" name="<?php echo $this->captcha_csrf['name']; ?>" id="<?php echo $this->captcha_csrf['name']; ?>" value="<?php echo $this->captcha_csrf['value']; ?>">
                        </div>
                    </li>
                <?php } ?>
            <?php } ?>

            <?php
            if(!empty($this->user_reg_extend['inputArray'])) {
                foreach($this->user_reg_extend['inputArray'] as $g_value) {
                    ?>
                    <li>
                        <div class="input-text">
                            <b>
                                <?php echo $this->escapeHtml($g_value['field_title']); ?>
                                <?php if(!empty($g_value['not_empty'])) { ?><font class="must_add_value">*</font><?php } ?>：
                            </b>
                                <span>
                                    <?php if($g_value['field_type'] == 'radio' and !empty($g_value['body'])) {
                                        foreach($g_value['body'] as $g_b_value) {
                                            ?>
                                            <input type="radio" name="<?php echo $g_value['name']; ?>" <?php if(!empty($g_value['not_empty'])) { ?>class="<?php echo $g_value['name']; ?>" datatype="*"<?php } ?> value="<?php echo $g_b_value[0]; ?>"><?php echo $g_b_value[1]; ?>&nbsp;
                                        <?php } } ?>
                                    <?php if($g_value['field_type'] == 'checkbox' and !empty($g_value['body'])) {
                                        foreach($g_value['body'] as $g_b_value) {
                                            ?>
                                            <input type="checkbox" name="<?php echo $g_value['name']; ?>[]" <?php if(!empty($g_value['not_empty'])) { ?>class="<?php echo $g_value['name']; ?>" datatype="*"<?php } ?> value="<?php echo $g_b_value[0]; ?>"><?php echo $g_b_value[1]; ?>&nbsp;
                                        <?php } } ?>
                                    <?php if($g_value['field_type'] == 'select' and !empty($g_value['body'])) {
                                        echo '<select name="'.$g_value['name'].'" id="'.$g_value['id'].'" '.(!empty($g_value['not_empty']) ? 'datatype="*"' : '').' class="span2">';
                                        foreach($g_value['body'] as $g_b_value) {
                                            ?>
                                            <option value="<?php echo $g_b_value[0]; ?>"><?php echo $g_b_value[1]; ?></option>
                                        <?php } echo '</select>'; } ?>
                                    <?php if($g_value['field_type'] == 'text') { ?>
                                        <input type="text" id="<?php echo $g_value['id']; ?>" name="<?php echo $g_value['name']; ?>" <?php if(!empty($g_value['not_empty'])) echo 'datatype="*" nullmsg="'.$g_value['not_empty'].'"'; ?>>
                                    <?php } ?>
                                    <?php if($g_value['field_type'] == 'textarea') { ?>
                                        <textarea name="<?php echo $g_value['name']; ?>" id="<?php echo $g_value['id']; ?>"  <?php if(!empty($g_value['not_empty'])) echo 'datatype="*" nullmsg="'.$g_value['not_empty'].'"'; ?>></textarea>
                                    <?php } ?>
                                    <?php if($g_value['field_type'] == 'upload') { ?>
                                        <input type="file" name="<?php echo $g_value['name']; ?>" id="<?php echo $g_value['id']; ?>" <?php if(!empty($g_value['not_empty'])) echo 'datatype="*" nullmsg="'.$g_value['not_empty'].'"'; ?>>
                                    <?php } ?>
                                </span>
                        </div>
                    </li>
                    <?php
                }
            }
            ?>
            <?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
            <li>
                <div class="input-text code"><b><?php echo $this->translate('验证码'); ?><font class="must_add_value">*</font>：</b><span>
                <input type="text" datatype="*" id="captcha_code" name="captcha_code" ajaxurl="<?php echo $this->url('mobile/default',array('action'=>'checkCaptcha')); ?>" placeholder="<?php echo $this->translate('请输入验证码'); ?>" nullmsg="<?php echo $this->translate('请输入验证码'); ?>">
                </span>
                    <img style="width: auto;" id="captcha_id" src="" onclick="captchaAdd();" class="pull-right">
                </div>
            </li>
            <?php } ?>
        </ul>
    </div>

    <p class="ect-checkbox ect-padding-tb ect-margin-tb ect-margin-bottom0 ect-padding-lr">
        <input type="checkbox" datatype="*" checked="checked" value="1" name="agreement" id="agreement"  nullmsg="<?php echo $this->translate('接受用户协议后，方可注册'); ?>">
        <label for="agreement"> <?php echo $this->translate('我已看过并接受'); ?>《<a target="_blank" style="color:blue" href="<?php echo $this->url('m_user/default',array('action'=>'registerInfo')); ?>"><?php echo $this->translate('用户协议'); ?></a>》<i></i></label>
    </p>
    <input type="hidden" name="<?php echo $this->register_csrf['name']; ?>" value="<?php echo $this->register_csrf['value']; ?>" />
    <input type="hidden" name="http_referer" value="<?php echo $this->http_referer; ?>" />
    <div class="ect-padding-lr ect-padding-tb"> <input type="submit" value="<?php echo $this->translate('注册会员'); ?>" class="btn btn-info ect-btn-info ect-colorf"></div>
</form>
    <?php if($this->frontwebsite()->getUserOtherLoginState() == 'true') { ?>
        <div class="ect-padding-lr ect-margin-tb user-hezuo">
            <?php echo $this->translate('使用合作账号登录'); ?>
            <?php
            $otherLoginArray = $this->frontwebsite()->getUserOtherLoginIni();
            if(!empty($otherLoginArray)) {
                foreach($otherLoginArray as $othKey => $othValue) {
                    if($othValue['login_state'] == 'true') {
                        $othKey = strtolower($othKey);
                        ?>
                        <p><a href="<?php echo $this->url('m_user/default',array('action'=>'otherlogin'), array('query'=>array('login_type'=>$othKey))); ?>"><img src="<?php echo $this->basePath('public/mobile/default/images/'.$othKey.'.png'); ?>"></a></p>
                        <?php
                    }
                }
            }
            ?>
        </div>
    <?php } ?>
<script>
    <?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
    //验证码添加
    function captchaAdd() {
        $.get("<?php echo $this->url('shopfront/default',array('action'=>'captcha')); ?>",{},
            function(data){
                $("#captcha_id").attr('src', '<?php echo $this->basePath('/'); ?>'+data.captcha_file);
            },'json');
    }
    captchaAdd();
    <?php } ?>

    <?php if ($userPhoneRegisterState == 'true' and $userPhoneCaptchaState == 'true') { ?>
    var waittime=<?php echo $this->frontwebsite()->websiteCaptchaState('phone_captcha_time'); ?>;
    function captchatime() {
        if (waittime == 0) {
            $('#user_phone').removeAttr("readonly");

            $('#get_phone_captcha').removeAttr("disabled");
            $('#get_phone_captcha').val('<?php echo $this->translate('获取验证码'); ?>');
            waittime = <?php echo $this->frontwebsite()->websiteCaptchaState('phone_captcha_time'); ?>;
        }
        else {
            $('#get_phone_captcha').val("<?php echo $this->translate('重新获取'); ?>(" + waittime + ")");
            waittime--;
            setTimeout(function() {
                    captchatime()
                },
                1000)
        }
    }
    document.getElementById("get_phone_captcha").onclick=function(){
        $.ajax({
            type : 'POST',
            url	 : '<?php echo $this->url('shopfront/default',array('action'=>'phoneCaptcha')); ?>',
            data : "user_phone="+$('#user_phone').val()+"&checkrepeat=true&captcha_security="+$('#captcha_security').val(),
            success: function(msg){
                if(msg != '') {
                    alert(msg);
                    return false;
                } else {
                    $('#user_phone').attr("readonly", true);
                    $('#get_phone_captcha').attr("disabled", true);
                    captchatime();
                }
            }
        });
    }
    <?php } ?>
</script>
<?php } else { ?>
    <p class="ect-checkbox ect-padding-tb ect-margin-tb ect-margin-bottom0 ect-padding-lr">
        <?php echo $this->frontwebsite()->getUserIni('register_close_message'); ?>
    </p>
<?php } ?>